
import { VuexModule, Module, Action, Mutation, getModule, MutationAction } from 'vuex-module-decorators';
import store from '@/store';
import servers from '@/servers/index'
@Module({ dynamic: true, store, name: 'JointInspection', namespaced: true })
class JointInspection extends VuexModule {
    CompanyList: any = [];      // 公共方法-当前用户所属地市
    LocalCityList: any = [];    // 公共方法-当前用户所属存在机器人的变电站List
    getDydjList: any = [];      // 公共方法，获取电压等级List
    getJhztList: any = [];      // 公共方法-获取巡视计划的计划状态List
    getWhbzList: any = [];      // 公共方法，获取维护班组List
    getXslxList: any = [];      // 公共方法-获取巡视类型或者巡检类型List
    getXsfsList: any = [];      // 公共方法-获取巡视计划的巡视方式List
    getXsjgList: any = [];      // 公共方法-获取巡视报告的巡检结果枚举
    getAreaList: any = [];      // 巡检点位管理-左侧树
    jclxData: any = [];         //巡视卡管理-环境监测的类型



    //公共方法-当前用户所属地市 
    @MutationAction({ mutate: ['CompanyList', 'getAreaList'] })
    async setCompanyList() {
        
        var list: any = await (servers as any)
            .getCurrentOrgNo({ data: {} }).then((res: any) => {
                // console.log(res.data, 8888888);
                return res.data
            })
            // console.log(21,list)
        if (list) {
            var list2: any = await (servers as any)
                .getAreaList({ data: { ssds: list[0].code } }).then((res: any) => {
                    // console.log(res.data, 999999);
                    if (res.data) {
                        return res.data
                    }
                })
                .catch((err: object) => {
                    console.log(err);
                });
        }
        // console.log(list,list2);
        return { CompanyList: list, getAreaList: list2 }
    }


    //公共方法-当前用户所属存在机器人的变电站
    @MutationAction({ mutate: ['LocalCityList'] })
    async setLocalCityList() {
        var list: any = await (servers as any)
            .getCurrentUserRobotStation({ data: {} }).then((res: any) => {
                // console.log(res.data,22222222222222222222222222222222);
                return res.data
            })
        // console.log(list);

        return { LocalCityList: list }
    }
    //公共方法，获取电压等级
    @MutationAction({ mutate: ['getDydjList'] })
    async setgetDydjList() {
        var list: any = await (servers as any)
            .getDydj({ data: {} }).then((res: any) => {
                // console.log(res.data);
                return res.data
            })
        // console.log(list);
        return { getDydjList: list }
    }
    //  公共方法-获取巡视计划的计划状态
    @MutationAction({ mutate: ['getJhztList'] })
    async setgetJhztList() {
        var list: any = await (servers as any)
            .getJhzt({ data: {} }).then((res: any) => {
                // console.log(res.data);
                return res.data
            })
        // console.log(list);
        return { getJhztList: list }
    }
    //公共方法，获取维护班组
    @MutationAction({ mutate: ['getWhbzList'] })
    async setgetWhbzList() {
        var list: any = await (servers as any)
            .getQueryWhbz({ data: {} }).then((res: any) => {
                // console.log(res.data);
                return res.data
            })
        console.log(list);
        return { getWhbzList: list }
    }
    //公共方法-获取巡视类型或者巡检类型
    @MutationAction({ mutate: ['getXslxList'] })
    async setgetXslxList() {
        var list: any = await (servers as any)
            .getXslx({ data: {} }).then((res: any) => {
                //   console.log(res.data,33333333333333);
                return res.data
            })
        console.log(list);
        return { getXslxList: list }
    }
    //公共方法-获取巡视计划的巡视方式
    @MutationAction({ mutate: ['getXsfsList'] })
    async setgetXsfsList() {
        var list: any = await (servers as any)
            .getXsfs({ data: {} }).then((res: any) => {
                // console.log(res.data);
                return res.data
            })
        // console.log(list);
        return { getXsfsList: list }
    }
    //公共方法-获取巡视报告的巡检结果枚举
    @MutationAction({ mutate: ['getXsjgList'] })
    async setgetXsjgList() {
        var list: any = await (servers as any)
            .getXsjg({ data: {} }).then((res: any) => {
                //  console.log(res.data,33333333333333333);
                return res.data
            })
        // console.log(list);
        return { getXsjgList: list }
    }
    //变电站树图
    // @MutationAction({ mutate: ['getAreaList'], })
    // async setgetAreaList(params) {
    //     console.log(params);

    //     var localCity = params && params[0] && params[0].code
    //     var list: any = await (servers as any)
    //         .getAreaList({ data: { ssds: localCity } }).then((res: any) => {
    //             // console.log(res.data,999999);
    //             if (res.data) {
    //                 return res.data
    //             }
    //         })
    //         .catch((err: object) => {
    //             console.log(err);
    //         });
    //     // console.log("999999999999999999:", list);
    //     return { getAreaList: list }
    // }

    // @Action({ commit: 'setarealistmutation' })
    // async getarealistaction(params: any) {
    //     var localCity = params && params[0] && params[0].code
    //     var list: any = await (servers as any)
    //         .getAreaList({ data: { ssds: localCity } }).then((res: any) => {
    //             // console.log(res.data,999999);
    //             if (res.data) {
    //                 return res.data
    //             }
    //         })
    //         .catch((err: object) => {
    //             console.log(err);
    //         });
    //     return list
    // }
    // @Mutation
    // setarealistmutation(list:any){
    //     this.getAreaList = list
    // }

    //环境监测的类型
    @MutationAction({ mutate: ['jclxData'] })
    async setgetHjjc() {
        var list: any = await (servers as any)
            .getHjjc({ data: {} }).then((res: any) => {
                //  console.log(res.data,33333333333333333);
                return res.data
            })
        // console.log(list);
        return { jclxData: list }
    }
}

export const JointInspectionModule = getModule(JointInspection);